package putYourHands.controllers;

import javax.servlet.ServletException;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.view.RedirectView;

import putYourHands.services.PacienteBean;
import putYourHands.services.PacienteService;

public class PacienteAltaFormController extends SimpleFormController {
	
	private PacienteService pacienteService;

    public PacienteService getPacienteService() {
		return pacienteService;
	}

	public void setPacienteService(PacienteService pacienteService) {
		this.pacienteService = pacienteService;
	}

	public ModelAndView onSubmit(Object command)
            throws ServletException {

        String nombre = ((PacienteBean) command).getNombre();
        String apellido = ((PacienteBean) command).getApellido();
        Integer dni = ((PacienteBean) command).getDni();

        pacienteService.altaPaciente(nombre, apellido, dni);

        return new ModelAndView(new RedirectView(getSuccessView()));
    }

}
